package com.yichen.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import imusic4j.interfaces.ActorAlbumInfo;

/**
 * 歌手和歌手歌曲
 * 
 * @author yangyong
 * 
 */
public class Actor_MusicUtils {

	ActorAlbumInfo a = new ActorAlbumInfo();

	public List<Map<String, String>> getMusicByActorID(String actor_id) {
		Log.v("msg", "歌手歌曲列表查询");
		List<Map<String, String>> re_list = new ArrayList<Map<String, String>>();
		String startNum = "1";
		String maxNum = "5";
		// System.out.println(a.findMusicOfActor(actor_id, startNum, maxNum));

		String json_str = a.findMusicOfActor(actor_id, startNum, maxNum);
		JSONObject json;
		try {
			json = new JSONObject(json_str);
			JSONObject queryBillboardListResponse = json
					.getJSONObject("queryMusicsResponse");

			// System.out.println("所有的歌曲" + json_str);

			JSONArray json_base = queryBillboardListResponse
					.getJSONArray("mitems");
			for (int j = 0; j < json_base.length(); j++) {
				JSONObject jj = (JSONObject) json_base.get(j);
				String music_name = jj.getString("name");
				String music_id = jj.getString("id");
				String actor_name = jj.getString("actorName");

				Map<String, String> re_map = new HashMap<String, String>();
				re_map.put("music_name", music_name);
				re_map.put("actor_name", actor_name);
				re_map.put("music_id", music_id);

				Log.v("actor_type_actor", music_name + music_id);
				re_list.add(re_map);

			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return re_list;

	}
	// String actorID = "6561";
	// String startNum = "1";
	// String maxNum = "5";
	// System.out.println(a.findMusicOfActor(actorID, startNum, maxNum));

}
